/* 
 * File:   NeuralLayer.h
 * Author: jcrada
 *
 * Created on October 23, 2008, 3:30 PM
 */

#ifndef _NEURALLAYER_H
#define	_NEURALLAYER_H
#include "Neuron.h"
#include <QtXml/QDomElement>
#include <QtXml/QDomDocument>
#include <assert.h>
namespace jcrada {

    class NeuralLayer {
    private:
        int _number_of_neurons;
        Neuron ** _neurons;
    protected:
        virtual void setNeuron(int index, Neuron* neuron){
            assert(index >=0 && index < getNumberOfNeurons());
            this->_neurons[index] = neuron;
        }

    public:
        NeuralLayer(int number_of_neurons);
        NeuralLayer( int number_of_neurons, int neuron_input_size );
        virtual ~NeuralLayer( );

        virtual NeuralLayer* clone() const;

        virtual void setActivationFunction(Neuron::eActivationFunction af);

        static NeuralLayer* fromXml( QDomElement& xml, bool* ok);
        virtual void toXml( QDomDocument& xml, QDomElement* parent = NULL ) const;

        virtual Neuron& getNeuron( int index ) const {
            assert(index >= 0 && index < getNumberOfNeurons());
            return *_neurons[index];
        }

        virtual int getNumberOfNeurons( ) const {
            return this->_number_of_neurons;
        }

        static int main( int argc, char** argv );
    };
}

#endif	/* _NEURALLAYER_H */

